package com.stm.bi.enums;

import java.util.Objects;

public enum Unit {

    INT(1, "整数"),
    TWO_DECIMAL(2, "小数"),
    TEN_THOUSAND(3, "万"),
    RATE(4, "率");

    private final Integer code;

    private final String desc;

    Unit(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public final int getCode() {
        return code;
    }

    public static Unit getUnit(Integer code) {
        for (Unit unit : Unit.values()) {
            if (Objects.equals(unit.getCode(), code)) {
                return unit;
            }
        }
        return null;
    }

}
